package com.wdd.libbase.view

import android.app.Dialog
import android.content.Context
import android.os.Bundle
import android.view.Gravity
import android.view.ViewGroup
import com.wdd.libbase.R

/**
 *
 * @ProjectName:    OwnTool
 * @Package:        com.wdd.libbase.view
 * @ClassName:      HttpDialog
 * @Description:     java类作用描述
 * @Author:         王丹丹
 * @CreateDate:     2019/12/4 13:37
 * @UpdateUser:     更新者
 * @UpdateDate:     2019/12/4 13:37
 * @UpdateRemark:   更新说明
 * @Version:        1.0
 */
class HttpDialog(context: Context?, themeResId: Int) : Dialog(context!!, themeResId) {

    constructor(context: Context?) : this(context, R.style.base_http_dialog)

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.base_http_dialog)
        setViewLocation()
    }

    /**
     * 设置dialog位于屏幕底部
     */
    private fun setViewLocation() {
        val window = this.window
        window!!.setGravity(Gravity.CENTER)
        val lp = window.attributes
        lp.width = ViewGroup.LayoutParams.WRAP_CONTENT
        lp.height = ViewGroup.LayoutParams.WRAP_CONTENT
        // 设置显示位置
        onWindowAttributesChanged(lp)
    }
}